package com.lt.ttl;

import com.lt.config.DelayedQueueConfig;
import com.lt.hello.HelloCustomer;
import com.lt.hello.HelloWorldConfig;
import com.rabbitmq.client.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author lucine
 * @version 1.0 2022/4/17 11:49
 */
@Component
public class TtlCustomer {

    public static final Logger logger = LoggerFactory.getLogger(TtlCustomer.class);

    int i = 0;
    @RabbitHandler
    @RabbitListener(
            queuesToDeclare = @Queue(value = DelayedQueueConfig.DELAYED_QUEUE_NAME
                    ,declare = "true",autoDelete = "false")
    )
    public void receive(Message message, Channel channel) throws Exception {
        logger.info(DelayedQueueConfig.DELAYED_QUEUE_NAME + "receive" +
                message.getMessageProperties().getDeliveryTag() + ":接收成功");
        //消息处理成功回调
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }
}
